<?php

namespace App\Http\Controllers\Home;

use App\Http\Controllers\Controller;
use App\Models\siteconfig;

class BaseController extends Controller
{

    public function __construct()
    {
        // 检查网站配置
        $this->checkWebsite();
    }

    public function checkWebsite(){
        $dn = siteconfig::checkWebsiteConfig();
        if($dn['code']==400){
             echo $this->createerrTml($dn['msg']);
             die;
        }
    }

    /**
     * 错误模板信息
     * @param $data
     * @return string
     */
    public function createerrTml($data){
        $html = "<!doctype html><html lang=\"en\"><head>" ;
        $html .= "<meta charset=\"UTF-8\"><meta name=\"viewport\"content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\"><meta http-equiv=\"X-UA-Compatible\"content=\"ie=edge\">";
        $html .= "<meta name =\"keywords\" content=".$data['keyword'].">
    <meta name=\"description\" content=".$data['desc'].">";
        $html .= '<title>'.$data['msg'].'-个人直播的平台</title>';
        $html .= '<style> .website_error { font-size: 28px; width: 100%; height:600px; text-align: center; line-height: 600px; position: fixed; color: #666; }</style>';
        $html .= '</head><body>';
        $html .= '<div class="website_error">'.$data['msg'].'</div>';
        $html .= '</body></html>';
        return $html;
    }
}
